// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import Vuex from 'vuex';
Vue.use(Vuex);
import store from './store/store.js'

require('swiper/dist/css/swiper.css')
import VueAwesomeSwiper from 'vue-awesome-swiper'
Vue.use(VueAwesomeSwiper)

import VueWechatTitle from 'vue-wechat-title';
Vue.use(VueWechatTitle);

import MintUI from 'mint-ui';
import 'mint-ui/lib/style.css';
Vue.use(MintUI);

import 'mescroll.js/mescroll.min.css';

import VueAMap from 'vue-amap';
import { lazyAMapApiLoaderInstance } from 'vue-amap';
Vue.use(VueAMap);

import axios from 'axios';
Vue.prototype.$ajax = axios;
axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
let token = window.localStorage.getItem('userToken') || '';
let syOpenId = window.localStorage.getItem('syOpenId') || '';

axios.defaults.headers['token'] = token;
console.log('token='+token);
console.log('syOpenId='+syOpenId);

import qs from 'qs';
/* 注入vue全局中，这样我们可以在组件内或者JS内通过使用this.$qs来使用qs库*/
Vue.prototype.$qs = qs;

// import { setMetaTitle } from './util/util.js'
require('@/assets/font-awesome-4.7.0/css/font-awesome.min.css');

import { configUrl } from '@/util/configUrl.js';
import { network } from '@/util/network.js';
import {MessageBox,Toast} from 'mint-ui';
import { reLoginWX } from '@/util/util.js';

window.eventBus = new Vue();  //自定义事件，传递参数

VueAMap.initAMapApiLoader({
  key: 'fb51c15db20503f6ca25a0525378a83a',
  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor', 'AMap.Geocoder'],
  // 默认高德 sdk 版本为 1.4.4
  v: '1.4.4'
});
lazyAMapApiLoaderInstance.load().then(() => {
  // your code ...
  this.map = new AMap.Map('amapContainer', {
    center: new AMap.LngLat(121.59996, 31.197646)
  });
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
});
Vue.directive('title', {
  inserted: function (el, binding) {
    // setMetaTitle(binding.value)
    document.title = binding.value;
  }
})
